package com.yphone.ui.ysj.view;

import android.support.v4.view.ViewPager;
import android.view.View;

public class CardTransformer implements ViewPager.PageTransformer {
    private static final float MIN_ALPHA = 0.5f;
    private static final float MIN_SCALE = 0.9f;

    public void transformPage(View page, float position) {
        if (position < -1.0f || position > 1.0f) {
            page.setAlpha(MIN_ALPHA);
            page.setScaleX(MIN_SCALE);
            page.setScaleY(MIN_SCALE);
        } else if (position <= 1.0f) {
            float scaleFactor = Math.max(MIN_SCALE, 1.0f - Math.abs(position));
            if (position < 0.0f) {
                float scaleX = 1.0f + (0.1f * position);
                page.setScaleX(scaleX);
                page.setScaleY(scaleX);
            } else {
                float scaleX2 = 1.0f - (0.1f * position);
                page.setScaleX(scaleX2);
                page.setScaleY(scaleX2);
            }
            page.setAlpha((((scaleFactor - MIN_SCALE) / 0.100000024f) * MIN_ALPHA) + MIN_ALPHA);
        }
    }
}